public class O27 {
    public static void main(String[] args) {
        TreeNode t = new TreeNode(1);
        t.left = new TreeNode(2);
        t.right = new TreeNode(3);
        O27 o = new O27();
        System.out.println(o.mirrorTree(t));
    }
    public TreeNode mirrorTree(TreeNode root) {
        if (root==null)
            return null;
        TreeNode l = root.left;
        root.left = mirrorTree(root.right);
        root.right = l;
        return root;
    }
    void dfs(TreeNode root,TreeNode tar){
        if (root.left!=null){
            tar.right = new TreeNode(root.left.val);
            dfs(root.left,tar.right);
        }
        if (root.right!=null){
            tar.left = new TreeNode(root.right.val);
            dfs(root.right,tar.left);
        }
    }
}
